package BasicClass.Two;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Two10 {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] s = reader.readLine().split(" ");
        int size = Integer.parseInt(s[0]);
        int target = Integer.parseInt(s[1]);
        String[] nums = reader.readLine().split(" ");
        int[] arr = new int[size];
        for (int i = 0; i < size; i++) {
            arr[i]=Integer.parseInt(nums[i]);
        }
        Two10 main = new Two10();
        main.partition(arr,target);
    }

    public void partition(int[] arr,int target){
        int left = 0;//表示小于区+1界外值，可直接返回当前值
        int right = arr.length-1;//表示大于区-1界外值
        int i = 0;
        while (i<=right){//判定条件为：当前指针越过right指针所在位置
            if(arr[i]==target){
                i++;
            }else if(arr[i]<target){//交换位置之后，需要再次判断交换后的数据属于哪个区域，所以i不++
                if(left==i){//若当前位置为区域界外值，i++，不需要换位置
                    i++;
                    left++;
                }else {
                    swap(arr,i,left);
                    left++;
                }
            }else {
                if(right==i){
                    i++;
                    right--;
                }else {
                    swap(arr,i,right);
                    right--;
                }
            }
        }
        if(left>right){
            System.out.println(-1+" "+-1);
        }else {
            System.out.println(left+" "+right);
        }
        System.out.println();
    }

    public void swap(int[] arr,int i,int j){
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }
}
